-
-
Notifications
You must be signed in to change notification settings - Fork 224
Implement GString concatenation operator #1117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement GString concatenation operator #1117
Conversation
Hi, and thanks for your contribution! 👍 I'm not sure the Instead of let a = GString::from(" is a ");
let b = GString::from("true");
let concat = &GString::from("12") + &a + &b + &GString::from(" number"); one can write let a = "is a";
let b = true;
let concat: GString = format!("12{a}{b} number").into(); Which has multiple advantages:
|
Hi @Bromeon, The verbosity of my example usage was mostly just due to to mirroring the logic originally employed by the In regard to performance, I do understand your concerns. My overall intention is to allow for a less lexically frictional experience for those adjusting to Rust from GDScript. Though operator overloading in this way may not be strictly so idiomatic for the avid Rust user, it does offer marginally greater parity with GDScript's syntax, which if that is not a primary priority for the GDExt project, then the closure of this pull request may indeed be appropriate. |
Please let me know if PierceLBrooks@7acaafc helps at all to minimize any of your performance concerns. |
Using Using a single
I understand, but in godot-rust we need to strike a balance between what's idiomatic in Rust and what's idiomatic in Godot. The The Potentially, we could also think about providing a format-style macro that internally calls let a = "is a";
let b = true;
let concat = godot_str!("12{a}{b} number"); What do you think about this? |
@PierceLBrooks would you be willing to change this PR to implement There is some prior art with the |
@Bromeon yes, I believe I will have enough free time to make a proper attempt at doing so before the weekend is over here. Thanks for the opportunity! |
Thanks to you! 😊 As mentioned, the already existing |
@PierceLBrooks have you had a chance to look into this yet? Let us know in case you get stuck somewhere! 🙂 |
@Bromeon , yes I have taken a look this week and will likely have conclusive progressive by the end of this weekend. The past week ended up being a little more chaotic than originally anticipated :P |
This will allow for users to add together their GString references with plus sign notation from within the Rust runtime of a gdextension, like so: